package MapEditor
{
	import Engine.Manager.ControlManager;
	import Engine.Manager.EngineManager;
	
	import GameMain.Model.GuiManager;
	
	import Interface.Common.IControlManager;
	import Interface.Common.IEngineManager;
	import Interface.Common.IGuiManager;
	
	import MapEditor.Editor.Editor;
	
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	
	[SWF(width="1000", height="600", frameRate="24", backgroundColor="#ffffff")]
	
	public class MapEditor extends Sprite
	{
		
		private static var _engineMgr:EngineManager = null;
		private static var _controlMgr:ControlManager = null;
		private static var _moduleMgr:GuiManager = null;
		
		private var _editor:Editor = null;
		
		
		public function MapEditor()
		{
			super();
			this.init();
			this.loadVersion();
		}
		
		
		public function get EngineMgr():IEngineManager
		{
			return _engineMgr;
		}
		
		public function get ControlMgr():IControlManager
		{
			return _controlMgr;
		}
		
		public function get ModuleMgr():IGuiManager
		{
			return _moduleMgr;
		}
		
		private function loadVersion():void
		{
			_engineMgr.loadURLResVersion(null,this.LoadEditor);
		}
		
		private function init():void
		{
			_engineMgr = new EngineManager;
			_controlMgr = new ControlManager;
			_engineMgr.addLogDebug(this);
			_moduleMgr = new GuiManager;
			_moduleMgr.addToParent(this);
		}
		
		private function LoadEditor():void
		{
			_engineMgr.loadSWF("MapEditorSwf.swf",onloadOver);
			_engineMgr.startloading();
		}
		
		private function onloadOver(e:Event,path:String):void
		{
			var info:LoaderInfo = e.currentTarget as LoaderInfo;
			this._editor = new Editor(info.content as Sprite,this);
			this.addChild(this._editor);
		}
	}
}